package com.aponisipsis.gl3d.importer.json;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;

import com.aponisipsis.gl3d.importer.ResourceLoader;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class JSONLoader implements ResourceLoader{
	private static Gson gson;
	
	static {
		gson = new  Gson();
	}

	public <T> T load(InputStream stream, Class<T> clazz){
		Type collectionType = TypeToken.get(clazz).getType();
		
		T object = gson.fromJson(new InputStreamReader(stream), collectionType);
		
		System.out.println(object);
		
		return object;
	}
	
}
